home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Entwickler / Mac-OS / oxygen / samples / docbook / xsl / common / common.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-09  |  49.3 KB  |  1,401 lines  |  [□□□□/□□□□]

  1. common.xsl¬ π¢tÚπ¢tÚÅÅK˚<?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  4.                 exclude-result-prefixes="doc"
  5.                 version='1.0'>
  6.  
  7. <!-- ********************************************************************
  8.      $Id: common.xsl,v 1.1 2002/05/29 09:55:12 dan Exp $
  9.      ********************************************************************
  10.  
  11.      This file is part of the XSL DocBook Stylesheet distribution.
  12.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  13.      and other information.
  14.  
  15.      This file contains general templates common to both the HTML and FO
  16.      versions of the DocBook stylesheets.
  17.      ******************************************************************** -->
  18.  
  19. <doc:reference xmlns="">
  20. <referenceinfo>
  21. <releaseinfo role="meta">
  22. $Id: common.xsl,v 1.1 2002/05/29 09:55:12 dan Exp $
  23. </releaseinfo>
  24. <author><surname>Walsh</surname>
  25. <firstname>Norman</firstname></author>
  26. <copyright><year>1999</year><year>2000</year>
  27. <holder>Norman Walsh</holder>
  28. </copyright>
  29. </referenceinfo>
  30. <title>Common Template Reference</title>
  31.  
  32. <partintro>
  33. <section><title>Introduction</title>
  34.  
  35. <para>This is technical reference documentation for the DocBook XSL
  36. Stylesheets; it documents (some of) the parameters, templates, and
  37. other elements of the stylesheets.</para>
  38.  
  39. <para>This is not intended to be <quote>user</quote> documentation.
  40. It is provided for developers writing customization layers for the
  41. stylesheets, and for anyone who's interested in <quote>how it
  42. works</quote>.</para>
  43.  
  44. <para>Although I am trying to be thorough, this documentation is known
  45. to be incomplete. Don't forget to read the source, too :-)</para>
  46. </section>
  47. </partintro>
  48.  
  49. </doc:reference>
  50.  
  51. <!-- ==================================================================== -->
  52. <!-- Establish strip/preserve whitespace rules -->
  53.  
  54. <xsl:preserve-space elements="*"/>
  55.  
  56. <xsl:strip-space elements="
  57. abstract affiliation anchor answer appendix area areaset areaspec
  58. artheader article audiodata audioobject author authorblurb authorgroup
  59. beginpage bibliodiv biblioentry bibliography biblioset blockquote book
  60. bookbiblio bookinfo callout calloutlist caption caution chapter
  61. citerefentry cmdsynopsis co collab colophon colspec confgroup
  62. copyright dedication docinfo editor entry entrytbl epigraph equation
  63. example figure footnote footnoteref formalpara funcprototype
  64. funcsynopsis glossary glossdef glossdiv glossentry glosslist graphicco
  65. group highlights imagedata imageobject imageobjectco important index
  66. indexdiv indexentry indexterm informalequation informalexample
  67. informalfigure informaltable inlineequation inlinemediaobject
  68. itemizedlist itermset keycombo keywordset legalnotice listitem lot
  69. mediaobject mediaobjectco menuchoice msg msgentry msgexplan msginfo
  70. msgmain msgrel msgset msgsub msgtext note objectinfo
  71. orderedlist othercredit part partintro preface printhistory procedure
  72. programlistingco publisher qandadiv qandaentry qandaset question
  73. refentry reference refmeta refnamediv refsect1 refsect1info refsect2
  74. refsect2info refsect3 refsect3info refsynopsisdiv refsynopsisdivinfo
  75. revhistory revision row sbr screenco screenshot sect1 sect1info sect2
  76. sect2info sect3 sect3info sect4 sect4info sect5 sect5info section
  77. sectioninfo seglistitem segmentedlist seriesinfo set setindex setinfo
  78. shortcut sidebar simplelist simplesect spanspec step subject
  79. subjectset substeps synopfragment table tbody textobject tfoot tgroup
  80. thead tip toc tocchap toclevel1 toclevel2 toclevel3 toclevel4
  81. toclevel5 tocpart varargs variablelist varlistentry videodata
  82. videoobject void warning subjectset
  83.  
  84. classsynopsis
  85. constructorsynopsis
  86. destructorsynopsis
  87. fieldsynopsis
  88. methodparam
  89. methodsynopsis
  90. ooclass
  91. ooexception
  92. oointerface
  93. simplemsgentry
  94. "/>
  95.  
  96. <!-- ====================================================================== -->
  97.  
  98. <doc:template name="is.component" xmlns="">
  99. <refpurpose>Tests if a given node is a component-level element</refpurpose>
  100.  
  101. <refdescription>
  102. <para>This template returns '1' if the specified node is a component
  103. (Chapter, Appendix, etc.), and '0' otherwise.</para>
  104. </refdescription>
  105.  
  106. <refparameter>
  107. <variablelist>
  108. <varlistentry><term>node</term>
  109. <listitem>
  110. <para>The node which is to be tested.</para>
  111. </listitem>
  112. </varlistentry>
  113. </variablelist>
  114. </refparameter>
  115.  
  116. <refreturn>
  117. <para>This template returns '1' if the specified node is a component
  118. (Chapter, Appendix, etc.), and '0' otherwise.</para>
  119. </refreturn>
  120. </doc:template>
  121.  
  122. <xsl:template name="is.component">
  123.   <xsl:param name="node" select="."/>
  124.   <xsl:choose>
  125.     <xsl:when test="local-name($node) = 'appendix'
  126.                     or local-name($node) = 'article'
  127.                     or local-name($node) = 'chapter'
  128.                     or local-name($node) = 'preface'
  129.                     or local-name($node) = 'bibliography'
  130.                     or local-name($node) = 'glossary'
  131.                     or local-name($node) = 'index'">1</xsl:when>
  132.     <xsl:otherwise>0</xsl:otherwise>
  133.   </xsl:choose>
  134. </xsl:template>
  135.  
  136. <!-- ====================================================================== -->
  137.  
  138. <doc:template name="is.section" xmlns="">
  139. <refpurpose>Tests if a given node is a section-level element</refpurpose>
  140.  
  141. <refdescription>
  142. <para>This template returns '1' if the specified node is a section
  143. (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
  144. </refdescription>
  145.  
  146. <refparameter>
  147. <variablelist>
  148. <varlistentry><term>node</term>
  149. <listitem>
  150. <para>The node which is to be tested.</para>
  151. </listitem>
  152. </varlistentry>
  153. </variablelist>
  154. </refparameter>
  155.  
  156. <refreturn>
  157. <para>This template returns '1' if the specified node is a section
  158. (Section, Sect1, Sect2, etc.), and '0' otherwise.</para>
  159. </refreturn>
  160. </doc:template>
  161.  
  162. <xsl:template name="is.section">
  163.   <xsl:param name="node" select="."/>
  164.   <xsl:choose>
  165.     <xsl:when test="local-name($node) = 'section'
  166.                     or local-name($node) = 'sect1'
  167.                     or local-name($node) = 'sect2'
  168.                     or local-name($node) = 'sect3'
  169.                     or local-name($node) = 'sect4'
  170.                     or local-name($node) = 'sect5'
  171.                     or local-name($node) = 'refsect1'
  172.                     or local-name($node) = 'refsect2'
  173.                     or local-name($node) = 'refsect3'
  174.                     or local-name($node) = 'simplesect'">1</xsl:when>
  175.     <xsl:otherwise>0</xsl:otherwise>
  176.   </xsl:choose>
  177. </xsl:template>
  178.  
  179. <!-- ====================================================================== -->
  180.  
  181. <doc:template name="section.level" xmlns="">
  182. <refpurpose>Returns the hierarchical level of a section.</refpurpose>
  183.  
  184. <refdescription>
  185. <para>This template calculates the hierarchical level of a section.
  186. Hierarchically, components are <quote>top level</quote>, so a
  187. <sgmltag>sect1</sgmltag> is at level 2, <sgmltag>sect3</sgmltag> is
  188. at level 3, etc.</para>
  189.  
  190. <para>Recursive sections are calculated down to the sixth level.</para>
  191. </refdescription>
  192.  
  193. <refparameter>
  194. <variablelist>
  195. <varlistentry><term>node</term>
  196. <listitem>
  197. <para>The section node for which the level should be calculated.
  198. Defaults to the context node.</para>
  199. </listitem>
  200. </varlistentry>
  201. </variablelist>
  202. </refparameter>
  203.  
  204. <refreturn>
  205. <para>The section level, <quote>2</quote>, <quote>3</quote>, etc.
  206. </para>
  207. </refreturn>
  208. </doc:template>
  209.  
  210. <xsl:template name="section.level">
  211.   <xsl:param name="node" select="."/>
  212.   <xsl:choose>
  213.     <xsl:when test="name($node)='sect1'">2</xsl:when>
  214.     <xsl:when test="name($node)='sect2'">3</xsl:when>
  215.     <xsl:when test="name($node)='sect3'">4</xsl:when>
  216.     <xsl:when test="name($node)='sect4'">5</xsl:when>
  217.     <xsl:when test="name($node)='sect5'">6</xsl:when>
  218.     <xsl:when test="name($node)='section'">
  219.       <xsl:choose>
  220.         <xsl:when test="$node/../../../../../section">6</xsl:when>
  221.         <xsl:when test="$node/../../../../section">5</xsl:when>
  222.         <xsl:when test="$node/../../../section">4</xsl:when>
  223.         <xsl:when test="$node/../../section">3</xsl:when>
  224.         <xsl:otherwise>2</xsl:otherwise>
  225.       </xsl:choose>
  226.     </xsl:when>
  227.     <xsl:when test="name($node)='refsect1'">2</xsl:when>
  228.     <xsl:when test="name($node)='refsect2'">3</xsl:when>
  229.     <xsl:when test="name($node)='refsect3'">4</xsl:when>
  230.     <xsl:when test="name($node)='simplesect'">
  231.       <xsl:choose>
  232.         <xsl:when test="$node/../../sect1">3</xsl:when>
  233.         <xsl:when test="$node/../../sect2">4</xsl:when>
  234.         <xsl:when test="$node/../../sect3">5</xsl:when>
  235.         <xsl:when test="$node/../../sect4">6</xsl:when>
  236.         <xsl:when test="$node/../../sect5">6</xsl:when>
  237.         <xsl:when test="$node/../../section">
  238.           <xsl:choose>
  239.             <xsl:when test="$node/../../../../../section">6</xsl:when>
  240.             <xsl:when test="$node/../../../../section">5</xsl:when>
  241.             <xsl:when test="$node/../../../section">4</xsl:when>
  242.             <xsl:otherwise>3</xsl:otherwise>
  243.           </xsl:choose>
  244.         </xsl:when>
  245.         <xsl:otherwise>2</xsl:otherwise>
  246.       </xsl:choose>
  247.     </xsl:when>
  248.     <xsl:otherwise>2</xsl:otherwise>
  249.   </xsl:choose>
  250. </xsl:template><!-- section.level -->
  251.  
  252. <doc:template name="qanda.section.level" xmlns="">
  253. <refpurpose>Returns the hierarchical level of a QandASet.</refpurpose>
  254.  
  255. <refdescription>
  256. <para>This template calculates the hierarchical level of a QandASet.
  257. </para>
  258. </refdescription>
  259.  
  260. <refreturn>
  261. <para>The level, <quote>1</quote>, <quote>2</quote>, etc.
  262. </para>
  263. </refreturn>
  264. </doc:template>
  265.  
  266. <xsl:template name="qanda.section.level">
  267.   <xsl:variable name="section"
  268.                 select="(ancestor::section
  269.                          |ancestor::simplesect
  270.                          |ancestor::sect5
  271.                          |ancestor::sect4
  272.                          |ancestor::sect3
  273.                          |ancestor::sect2
  274.                          |ancestor::sect1
  275.                          |ancestor::refsect3
  276.                          |ancestor::refsect2
  277.                          |ancestor::refsect1)[last()]"/>
  278.   <xsl:choose>
  279.     <xsl:when test="count($section) = '0'">1</xsl:when>
  280.     <xsl:otherwise>
  281.       <xsl:call-template name="section.level">
  282.         <xsl:with-param name="node" select="$section"/>
  283.       </xsl:call-template>
  284.     </xsl:otherwise>
  285.   </xsl:choose>
  286. </xsl:template>
  287.  
  288. <xsl:template name="qandadiv.section.level">
  289.   <xsl:variable name="section.level">
  290.     <xsl:call-template name="qanda.section.level"/>
  291.   </xsl:variable>
  292.   <xsl:variable name="anc.divs" select="ancestor::qandadiv"/>
  293.  
  294.   <xsl:value-of select="count($anc.divs) + number($section.level)"/>
  295. </xsl:template>
  296.  
  297. <xsl:template name="question.answer.label">
  298.   <xsl:variable name="deflabel">
  299.     <xsl:choose>
  300.       <xsl:when test="ancestor-or-self::*[@defaultlabel]">
  301.         <xsl:value-of select="(ancestor-or-self::*[@defaultlabel])[last()]
  302.                               /@defaultlabel"/>
  303.       </xsl:when>
  304.       <xsl:otherwise>
  305.         <xsl:value-of select="qanda.defaultlabel"/>
  306.       </xsl:otherwise>
  307.     </xsl:choose>
  308.   </xsl:variable>
  309.  
  310.   <xsl:variable name="label" select="@label"/>
  311.  
  312. <!--
  313.      (hnr      (hierarchical-number-recursive (normalize "qandadiv")
  314.                           node))
  315.  
  316.      (parsect  (ancestor-member node (section-element-list)))
  317.  
  318.      (defnum   (if (and %qanda-inherit-numeration% 
  319.                 %section-autolabel%)
  320.                (if (node-list-empty? parsect)
  321.                (section-autolabel-prefix node)
  322.                (section-autolabel parsect))
  323.                ""))
  324.  
  325.      (hnumber  (let loop ((numlist hnr) (number defnum) 
  326.                   (sep (if (equal? defnum "") "" ".")))
  327.              (if (null? numlist)
  328.              number
  329.              (loop (cdr numlist) 
  330.                    (string-append number
  331.                           sep
  332.                           (number->string (car numlist)))
  333.                    "."))))
  334.      (cnumber  (child-number (parent node)))
  335.      (number   (string-append hnumber 
  336.                   (if (equal? hnumber "")
  337.                       ""
  338.                       ".")
  339.                   (number->string cnumber))))
  340. -->
  341.  
  342.   <xsl:choose>
  343.     <xsl:when test="$deflabel = 'qanda'">
  344.       <xsl:call-template name="gentext">
  345.         <xsl:with-param name="key">
  346.           <xsl:choose>
  347.             <xsl:when test="local-name(.) = 'question'">question</xsl:when>
  348.             <xsl:when test="local-name(.) = 'answer'">answer</xsl:when>
  349.             <xsl:when test="local-name(.) = 'qandadiv'">qandadiv</xsl:when>
  350.             <xsl:otherwise>qandaset</xsl:otherwise>
  351.           </xsl:choose>
  352.         </xsl:with-param>
  353.       </xsl:call-template>
  354.     </xsl:when>
  355.     <xsl:when test="$deflabel = 'label'">
  356.       <xsl:value-of select="$label"/>
  357.     </xsl:when>
  358.     <xsl:when test="$deflabel = 'number'
  359.                     and local-name(.) = 'question'">
  360.       <xsl:apply-templates select="ancestor::qandaset[1]"
  361.                            mode="number"/>
  362.       <xsl:choose>
  363.         <xsl:when test="ancestor::qandadiv">
  364.           <xsl:apply-templates select="ancestor::qandadiv[1]"
  365.                                mode="number"/>
  366.           <xsl:apply-templates select="ancestor::qandaentry"
  367.                                mode="number"/>
  368.         </xsl:when>
  369.         <xsl:otherwise>
  370.           <xsl:apply-templates select="ancestor::qandaentry"
  371.                                mode="number"/>
  372.         </xsl:otherwise>
  373.       </xsl:choose>
  374.     </xsl:when>
  375.     <xsl:otherwise>
  376.       <!-- nothing -->
  377.     </xsl:otherwise>
  378.   </xsl:choose>
  379. </xsl:template>
  380.  
  381. <xsl:template match="qandaset" mode="number">
  382.   <!-- FIXME: -->
  383. </xsl:template>
  384.  
  385. <xsl:template match="qandadiv" mode="number">
  386.   <xsl:number level="multiple" from="qandaset" format="1."/>
  387. </xsl:template>
  388.  
  389. <xsl:template match="qandaentry" mode="number">
  390.   <xsl:choose>
  391.     <xsl:when test="ancestor::qandadiv">
  392.       <xsl:number level="single" from="qandadiv" format="1."/>
  393.     </xsl:when>
  394.     <xsl:otherwise>
  395.       <xsl:number level="single" from="qandaset" format="1."/>
  396.     </xsl:otherwise>
  397.   </xsl:choose>
  398. </xsl:template>
  399.  
  400. <!-- ====================================================================== -->
  401.  
  402. <xsl:template name="object.id">
  403.   <xsl:param name="object" select="."/>
  404.   <xsl:choose>
  405.     <xsl:when test="$object/@id">
  406.       <xsl:value-of select="$object/@id"/>
  407.     </xsl:when>
  408.     <xsl:otherwise>
  409.       <xsl:value-of select="generate-id($object)"/>
  410.     </xsl:otherwise>
  411.   </xsl:choose>
  412. </xsl:template>
  413.  
  414. <xsl:template name="person.name">
  415.   <!-- Return a formatted string representation of the contents of
  416.        the specified node (by default, the current element).
  417.        Handles Honorific, FirstName, SurName, and Lineage.
  418.        If %author-othername-in-middle% is #t, also OtherName
  419.        Handles *only* the first of each.
  420.        Format is "Honorific. FirstName [OtherName] SurName, Lineage"
  421.   -->
  422.   <xsl:param name="node" select="."/>
  423.  
  424.   <xsl:choose>
  425.     <!-- EXPERIMENTAL: the personname element is a specialcase -->
  426.     <xsl:when test="$node/personname">
  427.       <xsl:call-template name="person.name">
  428.         <xsl:with-param name="node" select="$node/personname"/>
  429.       </xsl:call-template>
  430.     </xsl:when>
  431.  
  432.     <!-- handle corpauthor as a special case...-->
  433.     <xsl:when test="name($node)='corpauthor'">
  434.       <xsl:apply-templates select="$node"/>
  435.     </xsl:when>
  436.  
  437.     <xsl:otherwise>
  438.       <xsl:variable name="h_nl" select="$node//honorific[1]"/>
  439.       <xsl:variable name="f_nl" select="$node//firstname[1]"/>
  440.       <xsl:variable name="o_nl" select="$node//othername[1]"/>
  441.       <xsl:variable name="s_nl" select="$node//surname[1]"/>
  442.       <xsl:variable name="l_nl" select="$node//lineage[1]"/>
  443.  
  444.       <xsl:variable name="has_h" select="$h_nl"/>
  445.       <xsl:variable name="has_f" select="$f_nl"/>
  446.       <xsl:variable name="has_o"
  447.                     select="$o_nl and ($author.othername.in.middle != 0)"/>
  448.       <xsl:variable name="has_s" select="$s_nl"/>
  449.       <xsl:variable name="has_l" select="$l_nl"/>
  450.  
  451.       <xsl:choose>
  452.         <xsl:when test="$node/@role = 'family-given'">
  453.           <!-- The family-given style applies a convention for identifying given -->
  454.           <!-- and family names in locales where it may be ambiguous -->
  455.           <xsl:if test="$has_h">
  456.             <xsl:value-of select="$h_nl"/>
  457.             <xsl:value-of select="$punct.honorific"/>
  458.           </xsl:if>
  459.  
  460.           <xsl:if test="$has_s">
  461.             <xsl:if test="$has_h">
  462.               <xsl:text> </xsl:text>
  463.             </xsl:if>
  464.             <xsl:value-of select="$s_nl"/>
  465.           </xsl:if>
  466.  
  467.           <xsl:if test="$has_o">
  468.             <xsl:if test="$has_h or $has_f"><xsl:text> </xsl:text></xsl:if>
  469.             <xsl:value-of select="$o_nl"/>
  470.           </xsl:if>
  471.  
  472.           <xsl:if test="$has_f">
  473.             <xsl:if test="$has_h or $has_s or $has_o"><xsl:text> </xsl:text></xsl:if>
  474.             <xsl:value-of select="$f_nl"/>
  475.           </xsl:if>
  476.  
  477.           <xsl:if test="$has_l">
  478.             <xsl:text>, </xsl:text>
  479.             <xsl:value-of select="$l_nl"/>
  480.           </xsl:if>
  481.  
  482.           <xsl:text> [FAMILY Given]</xsl:text>
  483.         </xsl:when>
  484.         <xsl:otherwise>
  485.           <xsl:if test="$has_h">
  486.             <xsl:value-of select="$h_nl"/>.
  487.           </xsl:if>
  488.  
  489.           <xsl:if test="$has_f">
  490.             <xsl:if test="$has_h"><xsl:text> </xsl:text></xsl:if>
  491.             <xsl:value-of select="$f_nl"/>
  492.           </xsl:if>
  493.  
  494.           <xsl:if test="$has_o">
  495.             <xsl:if test="$has_h or $has_f"><xsl:text> </xsl:text></xsl:if>
  496.             <xsl:value-of select="$o_nl"/>
  497.           </xsl:if>
  498.  
  499.           <xsl:if test="$has_s">
  500.             <xsl:if test="$has_h or $has_f or $has_o">
  501.               <xsl:text> </xsl:text>
  502.             </xsl:if>
  503.             <xsl:value-of select="$s_nl"/>
  504.           </xsl:if>
  505.  
  506.           <xsl:if test="$has_l">
  507.             <xsl:text>, </xsl:text>
  508.             <xsl:value-of select="$l_nl"/>
  509.           </xsl:if>
  510.         </xsl:otherwise>
  511.       </xsl:choose>
  512.     </xsl:otherwise>
  513.   </xsl:choose>
  514. </xsl:template> <!-- person.name -->
  515.  
  516. <xsl:template name="person.name.list">
  517.   <!-- Return a formatted string representation of the contents of
  518.        the current element. The current element must contain one or
  519.        more AUTHORs, CORPAUTHORs, OTHERCREDITs, and/or EDITORs.
  520.  
  521.        John Doe
  522.      or
  523.        John Doe and Jane Doe
  524.      or
  525.        John Doe, Jane Doe, and A. Nonymous
  526.   -->
  527.   <xsl:param name="person.list"
  528.              select="./author|./corpauthor|./othercredit|./editor"/>
  529.   <xsl:param name="person.count" select="count($person.list)"/>
  530.   <xsl:param name="count" select="1"/>
  531.  
  532.   <xsl:choose>
  533.     <xsl:when test="$count > $person.count"></xsl:when>
  534.     <xsl:otherwise>
  535.       <xsl:call-template name="person.name">
  536.         <xsl:with-param name="node" select="$person.list[position()=$count]"/>
  537.       </xsl:call-template>
  538.  
  539.       <xsl:choose>
  540.         <xsl:when test="$person.count = 2 and $count = 1">
  541.           <xsl:call-template name="gentext.template">
  542.             <xsl:with-param name="context" select="'authorgroup'"/>
  543.             <xsl:with-param name="name" select="'sep2'"/>
  544.           </xsl:call-template>
  545.         </xsl:when>
  546.         <xsl:when test="$person.count > 2 and $count+1 = $person.count">
  547.           <xsl:call-template name="gentext.template">
  548.             <xsl:with-param name="context" select="'authorgroup'"/>
  549.             <xsl:with-param name="name" select="'seplast'"/>
  550.           </xsl:call-template>
  551.         </xsl:when>
  552.         <xsl:when test="$count < $person.count">
  553.           <xsl:call-template name="gentext.template">
  554.             <xsl:with-param name="context" select="'authorgroup'"/>
  555.             <xsl:with-param name="name" select="'sep'"/>
  556.           </xsl:call-template>
  557.         </xsl:when>
  558.       </xsl:choose>
  559.  
  560.       <xsl:call-template name="person.name.list">
  561.         <xsl:with-param name="person.list" select="$person.list"/>
  562.         <xsl:with-param name="person.count" select="$person.count"/>
  563.         <xsl:with-param name="count" select="$count+1"/>
  564.       </xsl:call-template>
  565.     </xsl:otherwise>
  566.   </xsl:choose>
  567. </xsl:template><!-- person.name.list -->
  568.  
  569. <!-- === synopsis ======================================================= -->
  570. <!-- The following definitions match those given in the reference
  571.      documentation for DocBook V3.0
  572. -->
  573.  
  574. <xsl:variable name="arg.choice.opt.open.str">[</xsl:variable>
  575. <xsl:variable name="arg.choice.opt.close.str">]</xsl:variable>
  576. <xsl:variable name="arg.choice.req.open.str">{</xsl:variable>
  577. <xsl:variable name="arg.choice.req.close.str">}</xsl:variable>
  578. <xsl:variable name="arg.choice.plain.open.str"><xsl:text> </xsl:text></xsl:variable>
  579. <xsl:variable name="arg.choice.plain.close.str"><xsl:text> </xsl:text></xsl:variable>
  580. <xsl:variable name="arg.choice.def.open.str">[</xsl:variable>
  581. <xsl:variable name="arg.choice.def.close.str">]</xsl:variable>
  582. <xsl:variable name="arg.rep.repeat.str">...</xsl:variable>
  583. <xsl:variable name="arg.rep.norepeat.str"></xsl:variable>
  584. <xsl:variable name="arg.rep.def.str"></xsl:variable>
  585. <xsl:variable name="arg.or.sep"> | </xsl:variable>
  586. <xsl:variable name="cmdsynopsis.hanging.indent">4pi</xsl:variable>
  587.  
  588. <!-- ====================================================================== -->
  589.  
  590. <!--
  591. <xsl:template name="xref.g.subst">
  592.   <xsl:param name="string"></xsl:param>
  593.   <xsl:param name="target" select="."/>
  594.   <xsl:variable name="subst">%g</xsl:variable>
  595.  
  596.   <xsl:choose>
  597.     <xsl:when test="contains($string, $subst)">
  598.       <xsl:value-of select="substring-before($string, $subst)"/>
  599.       <xsl:call-template name="gentext.element.name">
  600.         <xsl:with-param name="element.name" select="name($target)"/>
  601.       </xsl:call-template>
  602.       <xsl:call-template name="xref.g.subst">
  603.         <xsl:with-param name="string"
  604.                         select="substring-after($string, $subst)"/>
  605.         <xsl:with-param name="target" select="$target"/>
  606.       </xsl:call-template>
  607.     </xsl:when>
  608.     <xsl:otherwise>
  609.       <xsl:value-of select="$string"/>
  610.     </xsl:otherwise>
  611.   </xsl:choose>
  612. </xsl:template>
  613.  
  614. <xsl:template name="xref.t.subst">
  615.   <xsl:param name="string"></xsl:param>
  616.   <xsl:param name="target" select="."/>
  617.   <xsl:variable name="subst">%t</xsl:variable>
  618.  
  619.   <xsl:choose>
  620.     <xsl:when test="contains($string, $subst)">
  621.       <xsl:call-template name="xref.g.subst">
  622.         <xsl:with-param name="string"
  623.                         select="substring-before($string, $subst)"/>
  624.         <xsl:with-param name="target" select="$target"/>
  625.       </xsl:call-template>
  626.       <xsl:call-template name="title.xref">
  627.         <xsl:with-param name="target" select="$target"/>
  628.       </xsl:call-template>
  629.       <xsl:call-template name="xref.t.subst">
  630.         <xsl:with-param name="string"
  631.                         select="substring-after($string, $subst)"/>
  632.         <xsl:with-param name="target" select="$target"/>
  633.       </xsl:call-template>
  634.     </xsl:when>
  635.     <xsl:otherwise>
  636.       <xsl:call-template name="xref.g.subst">
  637.         <xsl:with-param name="string" select="$string"/>
  638.         <xsl:with-param name="target" select="$target"/>
  639.       </xsl:call-template>
  640.     </xsl:otherwise>
  641.   </xsl:choose>
  642. </xsl:template>
  643.  
  644. <xsl:template name="xref.n.subst">
  645.   <xsl:param name="string"></xsl:param>
  646.   <xsl:param name="target" select="."/>
  647.   <xsl:variable name="subst">%n</xsl:variable>
  648.  
  649.   <xsl:choose>
  650.     <xsl:when test="contains($string, $subst)">
  651.       <xsl:call-template name="xref.t.subst">
  652.         <xsl:with-param name="string"
  653.                         select="substring-before($string, $subst)"/>
  654.         <xsl:with-param name="target" select="$target"/>
  655.       </xsl:call-template>
  656.       <xsl:call-template name="number.xref">
  657.         <xsl:with-param name="target" select="$target"/>
  658.       </xsl:call-template>
  659.       <xsl:call-template name="xref.t.subst">
  660.         <xsl:with-param name="string"
  661.                         select="substring-after($string, $subst)"/>
  662.         <xsl:with-param name="target" select="$target"/>
  663.       </xsl:call-template>
  664.     </xsl:when>
  665.     <xsl:otherwise>
  666.       <xsl:call-template name="xref.t.subst">
  667.         <xsl:with-param name="string" select="$string"/>
  668.         <xsl:with-param name="target" select="$target"/>
  669.       </xsl:call-template>
  670.     </xsl:otherwise>
  671.   </xsl:choose>
  672. </xsl:template>
  673.  
  674. <xsl:template name="subst.xref.text">
  675.   <xsl:param name="xref.text"></xsl:param>
  676.   <xsl:param name="target" select="."/>
  677.  
  678.   <xsl:call-template name="xref.n.subst">
  679.     <xsl:with-param name="string" select="$xref.text"/>
  680.     <xsl:with-param name="target" select="$target"/>
  681.   </xsl:call-template>
  682. </xsl:template>
  683. -->
  684.  
  685. <!-- ====================================================================== -->
  686.  
  687. <xsl:template name="filename-basename">
  688.   <!-- We assume all filenames are really URIs and use "/" -->
  689.   <xsl:param name="filename"></xsl:param>
  690.   <xsl:param name="recurse" select="false()"/>
  691.  
  692.   <xsl:choose>
  693.     <xsl:when test="substring-after($filename, '/') != ''">
  694.       <xsl:call-template name="filename-basename">
  695.         <xsl:with-param name="filename"
  696.                         select="substring-after($filename, '/')"/>
  697.         <xsl:with-param name="recurse" select="true()"/>
  698.       </xsl:call-template>
  699.     </xsl:when>
  700.     <xsl:otherwise>
  701.       <xsl:value-of select="$filename"/>
  702.     </xsl:otherwise>
  703.   </xsl:choose>
  704. </xsl:template>
  705.  
  706. <xsl:template name="filename-extension">
  707.   <xsl:param name="filename"></xsl:param>
  708.   <xsl:param name="recurse" select="false()"/>
  709.  
  710.   <!-- Make sure we only look at the base name... -->
  711.   <xsl:variable name="basefn">
  712.     <xsl:choose>
  713.       <xsl:when test="$recurse">
  714.         <xsl:value-of select="$filename"/>
  715.       </xsl:when>
  716.       <xsl:otherwise>
  717.         <xsl:call-template name="filename-basename">
  718.           <xsl:with-param name="filename" select="$filename"/>
  719.         </xsl:call-template>
  720.       </xsl:otherwise>
  721.     </xsl:choose>
  722.   </xsl:variable>
  723.  
  724.   <xsl:choose>
  725.     <xsl:when test="substring-after($basefn, '.') != ''">
  726.       <xsl:call-template name="filename-extension">
  727.         <xsl:with-param name="filename"
  728.                         select="substring-after($basefn, '.')"/>
  729.         <xsl:with-param name="recurse" select="true()"/>
  730.       </xsl:call-template>
  731.     </xsl:when>
  732.     <xsl:when test="$recurse">
  733.       <xsl:value-of select="$basefn"/>
  734.     </xsl:when>
  735.     <xsl:otherwise></xsl:otherwise>
  736.   </xsl:choose>
  737. </xsl:template>
  738.  
  739. <!-- ====================================================================== -->
  740.  
  741. <doc:template name="select.mediaobject" xmlns="">
  742. <refpurpose>Selects an appropriate media object from a list</refpurpose>
  743.  
  744. <refdescription>
  745. <para>This template examines a list of media objects (usually the
  746. children of a mediaobject or inlinemediaobject) and processes
  747. the "right" object.</para>
  748.  
  749. <para>This template relies on a template named "is.acceptable.mediaobject"
  750. to determine if a given object is an acceptable graphic. The semantics
  751. of media objects is that the first acceptable graphic should be used.
  752. </para>
  753.  
  754. <para>If no acceptable object is located, nothing happens.</para>
  755. </refdescription>
  756.  
  757. <refparameter>
  758. <variablelist>
  759. <varlistentry><term>olist</term>
  760. <listitem>
  761. <para>The node list of potential objects to examine.</para>
  762. </listitem>
  763. </varlistentry>
  764. </variablelist>
  765. </refparameter>
  766.  
  767. <refreturn>
  768. <para>Calls <xsl:apply-templates> on the selected object.</para>
  769. </refreturn>
  770. </doc:template>
  771.  
  772. <xsl:template name="select.mediaobject">
  773.   <xsl:param name="olist"
  774.              select="imageobject|imageobjectco
  775.                      |videoobject|audioobject|textobject"/>
  776.   <xsl:param name="count">1</xsl:param>
  777.  
  778.   <xsl:if test="$count <= count($olist)">
  779.     <xsl:variable name="object" select="$olist[position()=$count]"/>
  780.  
  781.     <xsl:variable name="useobject">
  782.       <xsl:choose>
  783.     <!-- The phrase is never used -->
  784.         <xsl:when test="name($object)='textobject' and $object/phrase">
  785.           <xsl:text>0</xsl:text>
  786.         </xsl:when>
  787.     <!-- The first textobject is a reasonable fallback -->
  788.         <xsl:when test="name($object)='textobject' and $object[not(@role) or @role!='tex']">
  789.           <xsl:text>1</xsl:text>
  790.         </xsl:when>
  791.     <!-- If there's only one object, use it -->
  792.     <xsl:when test="$count = 1 and count($olist) = 1">
  793.       <xsl:text>1</xsl:text>
  794.     </xsl:when>
  795.     <!-- Otherwise, see if this one is a useable graphic -->
  796.         <xsl:otherwise>
  797.           <xsl:choose>
  798.             <!-- peek inside imageobjectco to simplify the test -->
  799.             <xsl:when test="local-name($object) = 'imageobjectco'">
  800.               <xsl:call-template name="is.acceptable.mediaobject">
  801.                 <xsl:with-param name="object" select="$object/imageobject"/>
  802.               </xsl:call-template>
  803.             </xsl:when>
  804.             <xsl:otherwise>
  805.               <xsl:call-template name="is.acceptable.mediaobject">
  806.                 <xsl:with-param name="object" select="$object"/>
  807.               </xsl:call-template>
  808.             </xsl:otherwise>
  809.           </xsl:choose>
  810.         </xsl:otherwise>
  811.       </xsl:choose>
  812.     </xsl:variable>
  813.  
  814.     <xsl:choose>
  815.       <xsl:when test="$useobject='1'">
  816.         <xsl:apply-templates select="$object"/>
  817.       </xsl:when>
  818.       <xsl:otherwise>
  819.         <xsl:call-template name="select.mediaobject">
  820.           <xsl:with-param name="olist" select="$olist"/>
  821.           <xsl:with-param name="count" select="$count + 1"/>
  822.         </xsl:call-template>
  823.       </xsl:otherwise>
  824.     </xsl:choose>
  825.   </xsl:if>
  826. </xsl:template>
  827.  
  828. <doc:template name="is.acceptable.mediaobject" xmlns="">
  829. <refpurpose>Returns '1' if the specified media object is recognized.</refpurpose>
  830.  
  831. <refdescription>
  832. <para>This template examines a media object and returns '1' if the
  833. object is recognized as a graphic.</para>
  834. </refdescription>
  835.  
  836. <refparameter>
  837. <variablelist>
  838. <varlistentry><term>object</term>
  839. <listitem>
  840. <para>The media object to consider.</para>
  841. </listitem>
  842. </varlistentry>
  843. </variablelist>
  844. </refparameter>
  845.  
  846. <refreturn>
  847. <para>0 or 1</para>
  848. </refreturn>
  849. </doc:template>
  850.  
  851. <xsl:template name="is.acceptable.mediaobject">
  852.   <xsl:param name="object"></xsl:param>
  853.  
  854.   <xsl:variable name="filename">
  855.     <xsl:call-template name="mediaobject.filename">
  856.       <xsl:with-param name="object" select="$object"/>
  857.     </xsl:call-template>
  858.   </xsl:variable>
  859.  
  860.   <xsl:variable name="ext">
  861.     <xsl:call-template name="filename-extension">
  862.       <xsl:with-param name="filename" select="$filename"/>
  863.     </xsl:call-template>
  864.   </xsl:variable>
  865.  
  866.   <!-- there will only be one -->
  867.   <xsl:variable name="data" select="$object/videodata
  868.                                     |$object/imagedata
  869.                                     |$object/audiodata"/>
  870.  
  871.   <xsl:variable name="format" select="$data/@format"/>
  872.  
  873.   <xsl:variable name="graphic.format">
  874.     <xsl:if test="$format">
  875.       <xsl:call-template name="is.graphic.format">
  876.         <xsl:with-param name="format" select="$format"/>
  877.       </xsl:call-template>
  878.     </xsl:if>
  879.   </xsl:variable>
  880.  
  881.   <xsl:variable name="graphic.ext">
  882.     <xsl:if test="$ext">
  883.       <xsl:call-template name="is.graphic.extension">
  884.         <xsl:with-param name="ext" select="$ext"/>
  885.       </xsl:call-template>
  886.     </xsl:if>
  887.   </xsl:variable>
  888.  
  889.   <xsl:choose>
  890.     <xsl:when test="$graphic.format = '1'">1</xsl:when>
  891.     <xsl:when test="$graphic.ext = '1'">1</xsl:when>
  892.     <xsl:otherwise>0</xsl:otherwise>
  893.   </xsl:choose>
  894. </xsl:template>
  895.  
  896. <xsl:template name="mediaobject.filename">
  897.   <xsl:param name="object"></xsl:param>
  898.  
  899.   <xsl:variable name="data" select="$object/videodata
  900.                                     |$object/imagedata
  901.                                     |$object/audiodata
  902.                                     |$object"/>
  903.  
  904.   <xsl:variable name="filename">
  905.     <xsl:choose>
  906.       <xsl:when test="$data[@fileref]">
  907.         <xsl:value-of select="$data/@fileref"/>
  908.       </xsl:when>
  909.       <xsl:when test="$data[@entityref]">
  910.         <xsl:value-of select="unparsed-entity-uri($data/@entityref)"/>
  911.       </xsl:when>
  912.       <xsl:otherwise></xsl:otherwise>
  913.     </xsl:choose>
  914.   </xsl:variable>
  915.  
  916.   <xsl:variable name="has.ext" select="contains($filename, '.') != ''"/>
  917.  
  918.   <xsl:variable name="ext">
  919.     <xsl:choose>
  920.       <xsl:when test="contains($filename, '.')">
  921.         <xsl:call-template name="filename-extension">
  922.           <xsl:with-param name="filename" select="$filename"/>
  923.         </xsl:call-template>
  924.       </xsl:when>
  925.       <xsl:otherwise>
  926.         <xsl:value-of select="$graphic.default.extension"/>
  927.       </xsl:otherwise>
  928.     </xsl:choose>
  929.   </xsl:variable>
  930.  
  931.   <xsl:variable name="graphic.ext">
  932.     <xsl:call-template name="is.graphic.extension">
  933.       <xsl:with-param name="ext" select="$ext"/>
  934.     </xsl:call-template>
  935.   </xsl:variable>
  936.  
  937.   <xsl:choose>
  938.     <xsl:when test="not($has.ext)">
  939.       <xsl:choose>
  940.         <xsl:when test="$ext != ''">
  941.           <xsl:value-of select="$filename"/>
  942.           <xsl:text>.</xsl:text>
  943.           <xsl:value-of select="$ext"/>
  944.         </xsl:when>
  945.         <xsl:otherwise>
  946.           <xsl:value-of select="$filename"/>
  947.         </xsl:otherwise>
  948.       </xsl:choose>
  949.     </xsl:when>
  950.     <xsl:when test="not($graphic.ext)">
  951.       <xsl:choose>
  952.         <xsl:when test="$graphic.default.extension != ''">
  953.           <xsl:value-of select="$filename"/>
  954.           <xsl:text>.</xsl:text>
  955.           <xsl:value-of select="$graphic.default.extension"/>
  956.         </xsl:when>
  957.         <xsl:otherwise>
  958.           <xsl:value-of select="$filename"/>
  959.         </xsl:otherwise>
  960.       </xsl:choose>
  961.     </xsl:when>
  962.     <xsl:otherwise>
  963.       <xsl:value-of select="$filename"/>
  964.     </xsl:otherwise>
  965.   </xsl:choose>
  966. </xsl:template>
  967.  
  968. <!-- ====================================================================== -->
  969.  
  970. <doc:template name="check.id.unique" xmlns="">
  971. <refpurpose>Warn users about references to non-unique IDs</refpurpose>
  972. <refdescription>
  973. <para>If passed an ID in <varname>linkend</varname>,
  974. <function>check.id.unique</function> prints
  975. a warning message to the user if either the ID does not exist or
  976. the ID is not unique.</para>
  977. </refdescription>
  978. </doc:template>
  979.  
  980. <xsl:template name="check.id.unique">
  981.   <xsl:param name="linkend"></xsl:param>
  982.   <xsl:if test="$linkend != ''">
  983.     <xsl:variable name="targets" select="key('id',$linkend)"/>
  984.     <xsl:variable name="target" select="$targets[1]"/>
  985.  
  986.     <xsl:if test="count($targets)=0">
  987.       <xsl:message>
  988.     <xsl:text>Error: no ID for constraint linkend: </xsl:text>
  989.     <xsl:value-of select="$linkend"/>
  990.     <xsl:text>.</xsl:text>
  991.       </xsl:message>
  992.       <!--
  993.       <xsl:message>
  994.     <xsl:text>If the ID exists in your document, did your </xsl:text>
  995.         <xsl:text>XSLT Processor load the DTD?</xsl:text>
  996.       </xsl:message>
  997.       -->
  998.     </xsl:if>
  999.  
  1000.     <xsl:if test="count($targets)>1">
  1001.       <xsl:message>
  1002.     <xsl:text>Warning: multiple "IDs" for constraint linkend: </xsl:text>
  1003.     <xsl:value-of select="$linkend"/>
  1004.     <xsl:text>.</xsl:text>
  1005.       </xsl:message>
  1006.     </xsl:if>
  1007.   </xsl:if>
  1008. </xsl:template>
  1009.  
  1010. <doc:template name="check.idref.targets" xmlns="">
  1011. <refpurpose>Warn users about incorrectly typed references</refpurpose>
  1012. <refdescription>
  1013. <para>If passed an ID in <varname>linkend</varname>,
  1014. <function>check.idref.targets</function> makes sure that the element
  1015. pointed to by the link is one of the elements listed in
  1016. <varname>element-list</varname> and warns the user otherwise.</para>
  1017. </refdescription>
  1018. </doc:template>
  1019.  
  1020. <xsl:template name="check.idref.targets">
  1021.   <xsl:param name="linkend"></xsl:param>
  1022.   <xsl:param name="element-list"></xsl:param>
  1023.   <xsl:if test="$linkend != ''">
  1024.     <xsl:variable name="targets" select="key('id',$linkend)"/>
  1025.     <xsl:variable name="target" select="$targets[1]"/>
  1026.  
  1027.     <xsl:if test="count($target) > 0">
  1028.       <xsl:if test="not(contains(concat(' ', $element-list, ' '), name($target)))">
  1029.     <xsl:message>
  1030.       <xsl:text>Error: linkend (</xsl:text>
  1031.       <xsl:value-of select="$linkend"/>
  1032.       <xsl:text>) points to "</xsl:text>
  1033.       <xsl:value-of select="name($target)"/>
  1034.       <xsl:text>" not (one of): </xsl:text>
  1035.       <xsl:value-of select="$element-list"/>
  1036.     </xsl:message>
  1037.       </xsl:if>
  1038.     </xsl:if>
  1039.   </xsl:if>
  1040. </xsl:template>
  1041.  
  1042. <!-- ====================================================================== -->
  1043. <!-- Procedure Step Numeration -->
  1044.  
  1045. <xsl:param name="procedure.step.numeration.formats" select="'1aiAI'"/>
  1046.  
  1047. <xsl:template name="procedure.step.numeration">
  1048.   <xsl:param name="context" select="."/>
  1049.   <xsl:variable name="format.length"
  1050.                 select="string-length($procedure.step.numeration.formats)"/>
  1051.   <xsl:choose>
  1052.     <xsl:when test="local-name($context) = 'substeps'">
  1053.       <xsl:variable name="ssdepth"
  1054.                     select="count($context/ancestor::substeps)"/>
  1055.       <xsl:variable name="sstype" select="($ssdepth mod $format.length)+2"/>
  1056.       <xsl:choose>
  1057.         <xsl:when test="$sstype > $format.length">
  1058.           <xsl:value-of select="substring($procedure.step.numeration.formats,1,1)"/>
  1059.         </xsl:when>
  1060.         <xsl:otherwise>
  1061.           <xsl:value-of select="substring($procedure.step.numeration.formats,$sstype,1)"/>
  1062.         </xsl:otherwise>
  1063.       </xsl:choose>
  1064.     </xsl:when>
  1065.     <xsl:when test="local-name($context) = 'step'">
  1066.       <xsl:variable name="sdepth"
  1067.                     select="count($context/ancestor::substeps)"/>
  1068.       <xsl:variable name="stype" select="($sdepth mod $format.length)+1"/>
  1069.       <xsl:value-of select="substring($procedure.step.numeration.formats,$stype,1)"/>
  1070.     </xsl:when>
  1071.     <xsl:otherwise>
  1072.       <xsl:message>
  1073.         <xsl:text>Unexpected context in procedure.step.numeration: </xsl:text>
  1074.         <xsl:value-of select="local-name($context)"/>
  1075.       </xsl:message>
  1076.     </xsl:otherwise>
  1077.   </xsl:choose>
  1078. </xsl:template>
  1079.  
  1080. <xsl:template match="step" mode="number">
  1081.   <xsl:param name="rest" select="''"/>
  1082.   <xsl:param name="recursive" select="1"/>
  1083.   <xsl:variable name="format">
  1084.     <xsl:call-template name="procedure.step.numeration"/>
  1085.   </xsl:variable>
  1086.   <xsl:variable name="num">
  1087.     <xsl:number count="step" format="{$format}"/>
  1088.   </xsl:variable>
  1089.   <xsl:choose>
  1090.     <xsl:when test="$recursive != 0 and ancestor::step">
  1091.       <xsl:apply-templates select="ancestor::step[1]" mode="number">
  1092.         <xsl:with-param name="rest" select="concat('.', $num, $rest)"/>
  1093.       </xsl:apply-templates>
  1094.     </xsl:when>
  1095.     <xsl:otherwise>
  1096.       <xsl:value-of select="concat($num, $rest)"/>
  1097.     </xsl:otherwise>
  1098.   </xsl:choose>
  1099. </xsl:template>
  1100.  
  1101. <!-- ====================================================================== -->
  1102. <!-- OrderedList Numeration -->
  1103.  
  1104. <xsl:template name="next.numeration">
  1105.   <xsl:param name="numeration" select="'default'"/>
  1106.   <xsl:choose>
  1107.     <!-- Change this list if you want to change the order of numerations -->
  1108.     <xsl:when test="$numeration = 'arabic'">loweralpha</xsl:when>
  1109.     <xsl:when test="$numeration = 'loweralpha'">lowerroman</xsl:when>
  1110.     <xsl:when test="$numeration = 'lowerroman'">upperalpha</xsl:when>
  1111.     <xsl:when test="$numeration = 'upperalpha'">upperroman</xsl:when>
  1112.     <xsl:when test="$numeration = 'upperroman'">arabic</xsl:when>
  1113.     <xsl:otherwise>arabic</xsl:otherwise>
  1114.   </xsl:choose>
  1115. </xsl:template>
  1116.  
  1117. <xsl:template name="list.numeration">
  1118.   <xsl:param name="node" select="."/>
  1119.  
  1120.   <xsl:choose>
  1121.     <xsl:when test="$node/@numeration">
  1122.       <xsl:value-of select="$node/@numeration"/>
  1123.     </xsl:when>
  1124.     <xsl:otherwise>
  1125.       <xsl:choose>
  1126.         <xsl:when test="$node/ancestor::orderedlist">
  1127.           <xsl:call-template name="next.numeration">
  1128.             <xsl:with-param name="numeration">
  1129.               <xsl:call-template name="list.numeration">
  1130.                 <xsl:with-param name="node" select="$node/ancestor::orderedlist[1]"/>
  1131.               </xsl:call-template>
  1132.             </xsl:with-param>
  1133.           </xsl:call-template>
  1134.         </xsl:when>
  1135.         <xsl:otherwise>
  1136.           <xsl:call-template name="next.numeration"/>
  1137.         </xsl:otherwise>
  1138.       </xsl:choose>
  1139.     </xsl:otherwise>
  1140.   </xsl:choose>
  1141. </xsl:template>
  1142.  
  1143. <!-- ====================================================================== -->
  1144. <!-- ItemizedList "Numeration" -->
  1145.  
  1146. <xsl:template name="next.itemsymbol">
  1147.   <xsl:param name="itemsymbol" select="'default'"/>
  1148.   <xsl:choose>
  1149.     <!-- Change this list if you want to change the order of symbols -->
  1150.     <xsl:when test="$itemsymbol = 'disc'">round</xsl:when>
  1151.     <xsl:when test="$itemsymbol = 'round'">square</xsl:when>
  1152.     <xsl:otherwise>disc</xsl:otherwise>
  1153.   </xsl:choose>
  1154. </xsl:template>
  1155.  
  1156. <xsl:template name="list.itemsymbol">
  1157.   <xsl:param name="node" select="."/>
  1158.  
  1159.   <xsl:choose>
  1160.     <xsl:when test="$node/@mark">
  1161.       <xsl:value-of select="$node/@mark"/>
  1162.     </xsl:when>
  1163.     <xsl:otherwise>
  1164.       <xsl:choose>
  1165.         <xsl:when test="$node/ancestor::itemizedlist">
  1166.           <xsl:call-template name="next.itemsymbol">
  1167.             <xsl:with-param name="itemsymbol">
  1168.               <xsl:call-template name="list.itemsymbol">
  1169.                 <xsl:with-param name="node" select="$node/ancestor::itemizedlist[1]"/>
  1170.               </xsl:call-template>
  1171.             </xsl:with-param>
  1172.           </xsl:call-template>
  1173.         </xsl:when>
  1174.         <xsl:otherwise>
  1175.           <xsl:call-template name="next.itemsymbol"/>
  1176.         </xsl:otherwise>
  1177.       </xsl:choose>
  1178.     </xsl:otherwise>
  1179.   </xsl:choose>
  1180. </xsl:template>
  1181.  
  1182. <!-- ====================================================================== -->
  1183.  
  1184. <doc:template name="copyright.years" xmlns="">
  1185. <refpurpose>Print a set of years with collapsed ranges</refpurpose>
  1186.  
  1187. <refdescription>
  1188. <para>This template prints a list of year elements with consecutive
  1189. years printed as a range. In other words:</para>
  1190.  
  1191. <screen><![CDATA[<year>1992</year>
  1192. <year>1993</year>
  1193. <year>1994</year>]]></screen>
  1194.  
  1195. <para>is printed <quote>1992-1994</quote>, whereas:</para>
  1196.  
  1197. <screen><![CDATA[<year>1992</year>
  1198. <year>1994</year>]]></screen>
  1199.  
  1200. <para>is printed <quote>1992, 1994</quote>.</para>
  1201.  
  1202. <para>This template assumes that all the year elements contain only
  1203. decimal year numbers, that the elements are sorted in increasing
  1204. numerical order, that there are no duplicates, and that all the years
  1205. are expressed in full <quote>century+year</quote>
  1206. (<quote>1999</quote> not <quote>99</quote>) notation.</para>
  1207. </refdescription>
  1208.  
  1209. <refparameter>
  1210. <variablelist>
  1211. <varlistentry><term>years</term>
  1212. <listitem>
  1213. <para>The initial set of year elements.</para>
  1214. </listitem>
  1215. </varlistentry>
  1216. <varlistentry><term>print.ranges</term>
  1217. <listitem>
  1218. <para>If non-zero, multi-year ranges are collapsed. If zero, all years
  1219. are printed discretely.</para>
  1220. </listitem>
  1221. </varlistentry>
  1222. <varlistentry><term>single.year.ranges</term>
  1223. <listitem>
  1224. <para>If non-zero, two consecutive years will be printed as a range,
  1225. otherwise, they will be printed discretely. In other words, a single
  1226. year range is <quote>1991-1992</quote> but discretely it's
  1227. <quote>1991, 1992</quote>.</para>
  1228. </listitem>
  1229. </varlistentry>
  1230. </variablelist>
  1231. </refparameter>
  1232.  
  1233. <refreturn>
  1234. <para>This template returns the formatted list of years.</para>
  1235. </refreturn>
  1236. </doc:template>
  1237.  
  1238. <xsl:template name="copyright.years">
  1239.   <xsl:param name="years"/>
  1240.   <xsl:param name="print.ranges" select="1"/>
  1241.   <xsl:param name="single.year.ranges" select="0"/>
  1242.   <xsl:param name="firstyear" select="0"/>
  1243.   <xsl:param name="nextyear" select="0"/>
  1244.  
  1245.   <!--
  1246.   <xsl:message terminate="no">
  1247.     <xsl:text>CY: </xsl:text>
  1248.     <xsl:value-of select="count($years)"/>
  1249.     <xsl:text>, </xsl:text>
  1250.     <xsl:value-of select="$firstyear"/>
  1251.     <xsl:text>, </xsl:text>
  1252.     <xsl:value-of select="$nextyear"/>
  1253.     <xsl:text> (</xsl:text>
  1254.     <xsl:value-of select="$years[1]"/>
  1255.     <xsl:text>)</xsl:text>
  1256.   </xsl:message>
  1257.   -->
  1258.  
  1259.   <xsl:choose>
  1260.     <xsl:when test="$print.ranges = 0">
  1261.       <xsl:choose>
  1262.         <xsl:when test="count($years) = 1">
  1263.           <xsl:apply-templates select="$years[1]" mode="titlepage.mode"/>
  1264.         </xsl:when>
  1265.         <xsl:otherwise>
  1266.           <xsl:apply-templates select="$years[1]" mode="titlepage.mode"/>
  1267.           <xsl:text>, </xsl:text>
  1268.           <xsl:call-template name="copyright.years">
  1269.             <xsl:with-param name="years"
  1270.                             select="$years[position() > 1]"/>
  1271.             <xsl:with-param name="print.ranges" select="$print.ranges"/>
  1272.             <xsl:with-param name="single.year.ranges"
  1273.                             select="$single.year.ranges"/>
  1274.           </xsl:call-template>
  1275.         </xsl:otherwise>
  1276.       </xsl:choose>
  1277.     </xsl:when>
  1278.     <xsl:when test="count($years) = 0">
  1279.       <xsl:variable name="lastyear" select="$nextyear - 1"/>
  1280.       <xsl:choose>
  1281.         <xsl:when test="$firstyear = 0">
  1282.           <!-- there weren't any years at all -->
  1283.         </xsl:when>
  1284.         <xsl:when test="$firstyear = $lastyear">
  1285.           <xsl:value-of select="$firstyear"/>
  1286.         </xsl:when>
  1287.         <xsl:when test="$single.year.ranges = 0
  1288.                         and $lastyear = $firstyear + 1">
  1289.           <xsl:value-of select="$firstyear"/>
  1290.           <xsl:text>, </xsl:text>
  1291.           <xsl:value-of select="$lastyear"/>
  1292.         </xsl:when>
  1293.         <xsl:otherwise>
  1294.           <xsl:value-of select="$firstyear"/>
  1295.           <xsl:text>-</xsl:text>
  1296.           <xsl:value-of select="$lastyear"/>
  1297.         </xsl:otherwise>
  1298.       </xsl:choose>
  1299.     </xsl:when>
  1300.     <xsl:when test="$firstyear = 0">
  1301.       <xsl:call-template name="copyright.years">
  1302.         <xsl:with-param name="years"
  1303.                         select="$years[position() > 1]"/>
  1304.         <xsl:with-param name="firstyear" select="$years[1]"/>
  1305.         <xsl:with-param name="nextyear" select="$years[1] + 1"/>
  1306.         <xsl:with-param name="print.ranges" select="$print.ranges"/>
  1307.         <xsl:with-param name="single.year.ranges"
  1308.                         select="$single.year.ranges"/>
  1309.       </xsl:call-template>
  1310.     </xsl:when>
  1311.     <xsl:when test="$nextyear = $years[1]">
  1312.       <xsl:call-template name="copyright.years">
  1313.         <xsl:with-param name="years"
  1314.                         select="$years[position() > 1]"/>
  1315.         <xsl:with-param name="firstyear" select="$firstyear"/>
  1316.         <xsl:with-param name="nextyear" select="$nextyear + 1"/>
  1317.         <xsl:with-param name="print.ranges" select="$print.ranges"/>
  1318.         <xsl:with-param name="single.year.ranges"
  1319.                         select="$single.year.ranges"/>
  1320.       </xsl:call-template>
  1321.     </xsl:when>
  1322.     <xsl:otherwise>
  1323.       <!-- we have years left, but they aren't in the current range -->
  1324.       <xsl:choose>
  1325.         <xsl:when test="$nextyear = $firstyear + 1">
  1326.           <xsl:value-of select="$firstyear"/>
  1327.           <xsl:text>, </xsl:text>
  1328.         </xsl:when>
  1329.         <xsl:when test="$single.year.ranges = 0
  1330.                         and $nextyear = $firstyear + 2">
  1331.           <xsl:value-of select="$firstyear"/>
  1332.           <xsl:text>, </xsl:text>
  1333.           <xsl:value-of select="$nextyear - 1"/>
  1334.           <xsl:text>, </xsl:text>
  1335.         </xsl:when>
  1336.         <xsl:otherwise>
  1337.           <xsl:value-of select="$firstyear"/>
  1338.           <xsl:text>-</xsl:text>
  1339.           <xsl:value-of select="$nextyear - 1"/>
  1340.           <xsl:text>, </xsl:text>
  1341.         </xsl:otherwise>
  1342.       </xsl:choose>
  1343.       <xsl:call-template name="copyright.years">
  1344.         <xsl:with-param name="years"
  1345.                         select="$years[position() > 1]"/>
  1346.         <xsl:with-param name="firstyear" select="$years[1]"/>
  1347.         <xsl:with-param name="nextyear" select="$years[1] + 1"/>
  1348.         <xsl:with-param name="print.ranges" select="$print.ranges"/>
  1349.         <xsl:with-param name="single.year.ranges"
  1350.                         select="$single.year.ranges"/>
  1351.       </xsl:call-template>
  1352.     </xsl:otherwise>
  1353.   </xsl:choose>
  1354. </xsl:template>
  1355.  
  1356. <!-- ====================================================================== -->
  1357.  
  1358. <doc:template name="find.path.params" xmlns="">
  1359. <refpurpose>Search in a table for the "best" match for the node</refpurpose>
  1360.  
  1361. <refdescription>
  1362. <para>This template searches in a table for the value that most-closely
  1363. (in the typical best-match sense of XSLT) matches the current (element)
  1364. node location.</para>
  1365. </refdescription>
  1366. </doc:template>
  1367.  
  1368. <xsl:template name="find.path.params">
  1369.   <xsl:param name="node" select="."/>
  1370.   <xsl:param name="table" select="''"/>
  1371.   <xsl:param name="location">
  1372.     <xsl:call-template name="xpath.location">
  1373.       <xsl:with-param name="node" select="$node"/>
  1374.     </xsl:call-template>
  1375.   </xsl:param>
  1376.  
  1377.   <xsl:variable name="value">
  1378.     <xsl:call-template name="lookup.key">
  1379.       <xsl:with-param name="key" select="$location"/>
  1380.       <xsl:with-param name="table" select="$table"/>
  1381.     </xsl:call-template>
  1382.   </xsl:variable>
  1383.  
  1384.   <xsl:choose>
  1385.     <xsl:when test="$value != ''">
  1386.       <xsl:value-of select="$value"/>
  1387.     </xsl:when>
  1388.     <xsl:when test="contains($location, '/')">
  1389.       <xsl:call-template name="find.path.params">
  1390.         <xsl:with-param name="node" select="$node"/>
  1391.         <xsl:with-param name="table" select="$table"/>
  1392.         <xsl:with-param name="location" select="substring-after($location, '/')"/>
  1393.       </xsl:call-template>
  1394.     </xsl:when>
  1395.   </xsl:choose>
  1396. </xsl:template>
  1397.  
  1398. </xsl:stylesheet>
  1399.  
  1400. This resource fork intentionally left blank   ˇˇ